package com.game.utilities;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.apache.log4j.Logger;

/**
 * User: wattsc5
 * <p/>
 * Date: 2/29/12
 */
public class CommandArguments
{
	private static final Logger logger = Logger.getLogger(CommandArguments.class);

	private final List<String> arguments = new ArrayList<String>();

	/**
	 * Initializes a new instance of a CommandArguments.
	 * @param message the original message
	 */
	public CommandArguments(String message)
	{
		message = message.trim();
		StringTokenizer tokenizer = new StringTokenizer(message);

		while(tokenizer.hasMoreElements())
		{
			this.arguments.add(tokenizer.nextToken());
		}
	}

	public String getCommand()
	{
		return this.arguments.get(0);
	}

	public String getArgument(int index)
	{
		return this.arguments.get(index);
	}

	public int getArgumentAsInt(int index)
	{
		return Integer.parseInt(this.getArgument(index));
	}
}
